package com.example.computer_component_manager.activity

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import com.example.computer_component_manager.R
import com.example.computer_component_manager.util.DbUtil
import com.example.computer_component_manager.volley.VolleyApplication

/**
 * 显示我的信息界面
 * 本界面采用经典findViewById方式
 * 参考资料：
 * https://blog.csdn.net/weixin_44544354/article/details/104923946
 *
 * @author 1923111015董寺卓
 */

class ShowMineActivity : Activity() {

    private lateinit var tvMyInfo: TextView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_show_mine)
        initViews()
        tvMyInfo.text = resources.getString(R.string.my_info_pattern_format)
            .format(DbUtil.loginAdminUserInfo!!.name, DbUtil.loginAdminUserInfo!!.adminRole)
        findViewById<Button>(R.id.btnLogOut).setOnClickListener {
            val sharedPreferences = VolleyApplication.instance.sharedPreferences.edit()
            sharedPreferences.clear()
            sharedPreferences.apply()
            startActivity(Intent(this, LoginActivity::class.java))
            MenuActivity.instance?.finish()
            finish()
        }
    }

    private fun initViews() {
        tvMyInfo = findViewById(R.id.tvMyInfo)
    }


}